package com.book.servlet.action;

import com.book.service.BorrowService;
import com.book.service.impl.BorrowServiceImpl;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

@WebServlet("/delete-borrow")
public class DeleteBorrowServlet extends HttpServlet {
    BorrowService borrowService;

    @Override
    public void init() throws ServletException {
        borrowService = new BorrowServiceImpl();
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id = req.getParameter("id");
        borrowService.deleteBorrowById(Integer.valueOf(id));
        resp.sendRedirect("index");
    }

}
